package com.yanqu.road.server.cmd.activity.seacraftsouthsea;

import com.yanqu.road.pb.activity.SeacraftSouthSeaProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.activity.seacraftsouthsea.SeacraftSouthSeaMgr;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @Description
 * @Author cwq
 * @Data 2022/1/20 17:21
 */
@Cmd(code = CrossProtocol.C2_SEACRAFT_SOUTH_SEA_CHALLENGE, desc = "海上争霸 南海丝路 挑战")
public class CrossSeacraftSouthSeaChallengeCmd extends CrossUnionCommand {

    long userId;
    int activityId;
    long targetId;
    int type;
    /**
     * 血量低于多少百分比 自动购买buff （type =2 才需要）
     */
    int blood;
    /**
     * 自动购买buffId （type =2 才需要）
     */
    int buffId;

    long goldNum;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        SeacraftSouthSeaProto.SeacraftSouthSeaChallengeGameToCrossMsg reqMsg = SeacraftSouthSeaProto.SeacraftSouthSeaChallengeGameToCrossMsg.parseFrom(packet.getBytes());
        userId = packet.getPlayerId();
        activityId = reqMsg.getActivityId();
        targetId = reqMsg.getCtsMsg().getTargetId();
        type = reqMsg.getCtsMsg().getType();
        blood = reqMsg.getCtsMsg().getBlood();
        buffId = reqMsg.getCtsMsg().getBuffId();
        goldNum = reqMsg.getGoldNum();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(GameProtocol.S_SEACRAFT_SOUTH_SEA_CHALLENGE_FROM_CROSS, SeacraftSouthSeaMgr.challenge(activityId,userId,targetId,type,blood,buffId,goldNum));
        MessageHelper.sendPacket(serverId, userId, pbMsg);
    }

    @Override
    public void sendData() {

    }
}
